package com.xqls.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xqls.bean.RainwaterDischargeRealdataBean;
import com.xqls.dal.dao.RainwaterDischargeRealdataDao;
import com.xqls.dal.model.RainwaterDischargeRealdata;
import com.xqls.service.RainwaterDischargeRealdataService;
import com.xqls.util.ObjectUtil;

@Service
public class RainwaterDischargeRealdataServiceImpl implements RainwaterDischargeRealdataService {

	@Autowired
	private RainwaterDischargeRealdataDao realdataDao;

	@Override
	public List<Map<String, Object>> selectByMap(Map<String, Object> map) {
		return realdataDao.selectByMap(map);
	}

	public boolean insertRainwaterDischargeRealdataList(RainwaterDischargeRealdataBean dischargeRealdataBean) {

		RainwaterDischargeRealdata realdata = (RainwaterDischargeRealdata) ObjectUtil.transfer(dischargeRealdataBean, RainwaterDischargeRealdata.class);

		return realdataDao.insertRainwaterDischargeRealdataList(realdata) > 0;

	}

	public boolean updatetRainwaterDischargeRealdataList(RainwaterDischargeRealdataBean dischargeRealdataBean) {
		RainwaterDischargeRealdata realdata = (RainwaterDischargeRealdata) ObjectUtil.transfer(dischargeRealdataBean, RainwaterDischargeRealdata.class);
		return realdataDao.updateRainwaterDischargeRealdataList(realdata) > 0;
	}

	public RainwaterDischargeRealdataBean queryByDeviceNo(String deviceNo) {
		RainwaterDischargeRealdata dischargeRealdatas=realdataDao.selectByDeviceNo(deviceNo);
		if(dischargeRealdatas==null) return  null;
		return (RainwaterDischargeRealdataBean) ObjectUtil.transfer(dischargeRealdatas, RainwaterDischargeRealdataBean.class);
	}

	@Override
	public List<Map<String, Object>> queryAll() {
		return realdataDao.queryAll();
	}
	
	public RainwaterDischargeRealdata selectByDeviceNo(String deviceNo){
		return realdataDao.selectByDeviceNo(deviceNo);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<RainwaterDischargeRealdataBean> selectListByMap(Map<String, Object> map) {
		return ObjectUtil.transferList(realdataDao.selectListByMap(map),RainwaterDischargeRealdataBean.class);
	}

	@Override
	public List<RainwaterDischargeRealdata> selectRainwater() {
		return realdataDao.selectRainwater();
	}


}
